<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/2/20 0020
 * Time: 15:42
 */

//注册自加载

spl_autoload_register('autoload');

function autoload($class)
{
    require dirname($_SERVER['SCRIPT_FILENAME']) . '//..//' . str_replace('\\', '/', $class) . '.php';
}

/*
 * 原型模式
 * 用于创建对象成本过高时
 */

/*********** test *************/

use prototype\Prototype;

//创建一个原型对象
$prototype = new Prototype();

//获取一个原型的克隆
$prototypeCloneOne = $prototype->getPrototype();
$prototypeCloneOne->_name = 'one';
$prototypeCloneOne->getName();

$prototypeCloneTwo = $prototype->getPrototype();
$prototypeCloneTwo->_name = 'two';
$prototypeCloneTwo->getName();

$prototypeCloneOne->getName();
